-- example: type class (redefinition) --
library ieee;
   use ieee.std_logic_1164.all;
package element_pack_typeclass is

type Element is class
   class attribute Value1: integer;
   class attribute Value2: integer;
   impure function get_value1 return integer;
   impure function get_value2 return integer;
   impure function equal(Other: Element'CLASS) return boolean;
end class Element;

type Element is class body
   impure function get_value1 return integer is
   begin
      return Value1;
   end;
   impure function get_value2 return integer is
   begin
      return Value2;
   end;
   impure function equal(Other: Element'CLASS) return boolean is
   begin
      return ((Value1=Other.get_value1) and
              (Value2=Other.get_value2));
   end;

base class
type Child_Of_Element is new class Element with
   impure function equal(Other: Element'CLASS) return boolean;
end class Child_Of_Element;

type Child_Of_Element is class body
   impure function equal(Other: Element'CLASS) return boolean is
   -- redefines former method "equal"
   begin
      return (Value1=Other.get_value1);
   end;
end class body Child_Of_Element;
end package;
derived classes